#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int main()
{
	int i, r, j, a, n, b, sum;
	scanf("%d", &r);
	for (i = 0; i < r; i++) {
		scanf("%d %d", &a, &n);
		sum = 0; b = a;
		for (j = 0; j < n; j++) {
			sum = sum + b;
			b = a + b * 10;
		}
		printf("%d\n", sum);
	}
	return 0;
}
//1085